package top.raoqq.sky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.raoqq.sky.constant.ConfigKeyConstant;
import top.raoqq.sky.constant.ConfigValueConstant;
import top.raoqq.sky.entity.sql.Config;
import top.raoqq.sky.mapper.ConfigMapper;
import top.raoqq.sky.mapper.MenuMapper;
import top.raoqq.sky.mapper.UserMapper;
import top.raoqq.sky.service.ConfigService;

import java.util.List;
import java.util.Objects;

/**
 * @author 饶奇奇
 * @date 2023/8/3
 */
@Service
@RequiredArgsConstructor
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {



    @Override
    public boolean enableCaptcha() {
        // 查看验证码功能是否开启
        LambdaQueryWrapper<Config> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Config::getConfigKey, ConfigKeyConstant.CAPTCHA_ENABLE);
        Config config = baseMapper.selectOne(wrapper);
        // 验证码开启参数为true则为开启，否则一律为不开启
        return Objects.nonNull(config) && ConfigValueConstant.ENABLE_CAPTCHA.equals(config.getConfigValue());
    }


}
